package top.lishuoboy.knife4j.swagger3_0_10.controller;

import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lishuoboy.knife4j.swagger3_0_10.entry.User;

@Tag(name = "用户管理")
@RestController
@RequestMapping("user")
public class MyUserController {

    /** 获取用户 */
    @Operation(summary = "获取用户", description = "获取用户详细说明")
    @Parameter(name = "implicitParam1", description = "隐式参数1", required = true)
    @Parameters({
        @Parameter(name = "implicitParam2", description = "隐式参数2"),
        @Parameter(name = "implicitParam3", description = "隐式参数3")
    })
    // 响应码说明
    @ApiResponses({
        @ApiResponse(responseCode = "404", description = "Not Found页面没找到"),
        @ApiResponse(responseCode = "888", description = "你猜"),
    })
    @GetMapping("getUser")
    public User getUserById(@Parameter(name = "id", description = "用户ID", required = true) int id) {
        return User.builder().id(1).userName("张三").build();
    }

    /** 新增用户 */
    @Operation(summary = "新增用户", description = "新增用户详细说明")
    @PostMapping("/postUser")
    public String postUser(User user) {
        return StrUtil.format("【postUser】。user=={}", user);
    }

    @RequestMapping("/requestMethod")
    public String requestMethod() {
        return StrUtil.format("【requestMethod】");
    }

    @Hidden  // 或 @Parameter(hidden = true) 或 @Operation(hidden = true) 忽略，当前注解描述的方法或类型，不生成api帮助文档。
    @RequestMapping("/apiIgnore")
    public String apiIgnore() {
        return StrUtil.format("【apiIgnore】");
    }
}